home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / visds / mmplay.dsc < prev    next >
Text File  |  1999-05-02  |  2KB  |  104 lines

  1.     title Drag'n'Play
  2.     rem VDS example script; author: Julian Moss
  3.   DIALOG CREATE,Drag'n'Play,100,100,256,112,DRAGDROP
  4.   DIALOG ADD,TEXT,T1,10,10,160,80
  5.     DIALOG ADD,CHECK,CB,10,180,,,AutoPlay,1
  6.     DIALOG ADD,BUTTON,Play,32,180
  7.     DIALOG ADD,BUTTON,Stop,62,180
  8.     DIALOG ADD,STATUS,SP,Drag files to the window to play them
  9.   DIALOG SHOW
  10.     dialog disable,Play
  11.     dialog disable,Stop
  12.     if %2
  13.         %F = %2
  14.         goto file
  15.     end
  16. :loop
  17.     wait event
  18.     goto @event()
  19. :close
  20.     goto closemedia
  21. :dragdrop
  22.     rem this event is generated when file(s) are dropped
  23.     gosub closemedia
  24.     list create,1
  25.     rem get the list of files
  26.     list dropfiles,1
  27.     rem use the first filename only
  28.     %F = @next(1)
  29.     list close,1
  30. :file
  31.     rem accept only WAV, MID, RMI or AVI files
  32.     if @equal(@ext(%F),WAV)@equal(@ext(%F),MID)@equal(@ext(%F),RMI)@equal(@ext(%F),AVI)
  33.         dialog clear,SP
  34.         %X = @name(%F).@ext(%F)@CR()
  35.         %R = @mci(open @shortname(%F) alias media wait)
  36.         if @ok()
  37.             %R = @mci(set media time format ms))
  38.             if @equal(@ext(%F),WAV)
  39.                 %R = @mci(status media channels)
  40.                 if @equal(%R,1)
  41.                     %X = %XMono@CR()
  42.                 else
  43.                     %X = %XStereo@CR()
  44.                 end
  45.                 %R = @mci(status media bitspersample)
  46.                 %X = %X%R bits per sample@CR()
  47.                 %R = @mci(status media samplespersec)
  48.                 %X = %X@fdiv(%R,1000)kHz sampling rate@CR()
  49.             end
  50.             %T = @mci(status media length)
  51.             if @greater(60000,%T)
  52.                 %R = @format(@fdiv(%T,1000),4.1) seconds
  53.             else
  54.                 %R = @format(@fdiv(%T,60000),4.1) minutes
  55.             end
  56.             %X = %XLength %R
  57.             dialog set,T1,%X
  58.             if @equal(@ext(%F),AVI)
  59.                 window position,#AVIWnd,100,360
  60.                 %R = @mci(window media state show wait)
  61.             end
  62.             if @dlgtext(CB)
  63.                 goto playmedia
  64.             else
  65.                 dialog enable,Play
  66.             end
  67.         end
  68.     end
  69.     goto loop
  70. :playbutton
  71.     goto playmedia
  72. :stopbutton
  73.     %R = @mci(stop media)
  74.     dialog clear,SP
  75.     dialog enable,Play
  76.     dialog disable,Stop
  77.     goto loop
  78. :playmedia
  79.     dialog enable,Stop
  80.     dialog disable,Play
  81.     %R = @mci(seek media to start)
  82.     dialog set,SP,Playing: 0%
  83.     %R = @mci(play media)
  84. :ploop
  85.     %P = %R
  86.     wait 2,event
  87.     goto @event()
  88. :timer
  89.     %R = @mci(status media position)
  90.     dialog set,SP,Playing: @div(@prod(%R,100),%T)%
  91.     if @not(@equal(%R,%P))
  92.         goto ploop
  93.     end
  94.     dialog clear,SP
  95. else
  96.     warn MCI error: %R
  97. end
  98. dialog enable,Play
  99. dialog disable,Stop
  100. goto loop
  101. :closemedia
  102. %R = @mci(close media)
  103. exit
  104.